var webdriver = require("selenium-webdriver"),
	By = webdriver.By,
	until = webdriver.until;

var driver = new webdriver.Builder()
	.forBrowser('firefox')
	.build();
	
driver.get('http://www.google.com');

driver.findElement(webdriver.By.name('q'))
	.sendKeys('Cheese');
driver.findElement(By.name('btnK')).click();

driver.getTitle().then(function(title) {
  console.log('1 Page title is: ' + title);
});

driver.wait(until.titleContains('Cheese - Google'), 3000);

driver.getTitle().then(function(title) {
  console.log('2 Page title is: ' + title);
});

driver.quit();